/*河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
*/
package cn.javaxc.system.action.system;
import java.io.*;
import java.util.*;
import java.sql.*;
import cn.javaxc.model.base.SQL;
import cn.javaxc.model.base.SQLList;
import cn.javaxc.model.base.SQLMap;
import cn.javaxc.model.base.SQLParam;
import cn.javaxc.model.page.BatisPage;
import cn.javaxc.mvcwork.controller.web.TreeBean;
import cn.javaxc.mvcwork.util.common.CommonUtil;
import cn.javaxc.mvcwork.util.common.MapListUtil;
import cn.javaxc.mvcwork.util.helper.FrameHelper;
import cn.javaxc.mvcwork.util.helper.TreeTableHelper;
import org.springframework.beans.factory.annotation.Autowired;
import cn.javaxc.system.action.base.BaseAction;
import cn.javaxc.system.mapper.system.PubFileMapper;
public class PubFile extends BaseAction
{
    @Autowired(required=false)
	private PubFileMapper mapper;
    public void hasPermission(){
        String sql="";
        String pagesql="";
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        
    }
    /**
    公共文件
    */
    
    public Map pubFile() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        TreeBean tb;
        
        tb = createTreeBean("s_tree_treecols");
        tb.setPrefix("img");
        SQLList<SQLMap> s_tree=mapper.s_tree(params);
        s_tree = s_tree.buildTree(tb,tb.getPid());
        result.put("s_tree", s_tree);
        
        return result;
    }
    /**
    发布文件流程
    */
    
    public Map publishFileStream() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        Object CMIDplan_id =mapper.CMIDplan_id(params);
        result.put("CMIDplan_id", CMIDplan_id);
        
        
        SQLList<SQLMap> t_plan=mapper.t_plan(params);
        SQLMap t_plan_emt=t_plan.getExistfirst();
        result.put("t_plan", t_plan_emt);
        
        return result;
    }
    /**
    转移文件
    */
    
    public Map pubFileMove() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        TreeBean tb;
        
        tb = createTreeBean("s_folders_treecols");
        tb.setPrefix("img");
        SQLList<SQLMap> s_folders=mapper.s_folders(params);
        s_folders = s_folders.buildTree(tb,tb.getPid());
        result.put("s_folders", s_folders);
        
        return result;
    }
    /**
    公共文件夹
    */
    
    public Map pubFileList() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.def("CMID9",-1);
        SQLList<SQLMap> s_folder=mapper.s_folder(params);
        result.put("s_folder", s_folder);
        
        
        params.def("CMID9",-1);
        SQLList<SQLMap> s_tree_menu=mapper.s_tree_menu(params);
        result.put("s_tree_menu", s_tree_menu);
        
        return result;
    }
    /**
    */
    
    public Object s_file() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> p_file=mapper.p_file(params,pagination);
        p_file.setPagedListInfo(pagination);
        result.put("p_file", p_file);
        
        return p_file;
    }
    /**
    文件版本
    */
    
    public Map pubFileVersion() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> s_file_version=mapper.s_file_version(params);
        result.put("s_file_version", s_file_version);
        
        return result;
    }
    /**
    上传文件备份
    */
    
    public Map pubFileUpload() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> s_1=mapper.s_1(params);
        result.put("s_1", s_1);
        
        return result;
    }
    /**
    上传文件
    */
    
    public Map uploadFilesStr() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        result.put("ts_files", create_code(18,"files_barcode"));
        
        return result;
    }
    /**
    增加版本
    */
    
    public Map pubFileAddVersion() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> s_file=mapper.s_file(params);
        SQLMap s_file_emt=s_file.getExistfirst();
        result.put("s_file", s_file_emt);
        
        return result;
    }
    /**
    新文件
    */
    
    public Map pubFileFolder() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> newfile=mapper.newfile(params);
        SQLMap newfile_emt=newfile.getExistfirst();
        result.put("newfile", newfile_emt);
        
        return result;
    }
    /**
    搜索文件
    */
    
    public Map pubFileSearch() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        result.put("s_search", pagination.getSearchParas());
        
        
        Object aCM =mapper.aCM(params);
        result.put("aCM", aCM);
        
        
        params.def("CMID9",-1);
        SQLList<SQLMap> s_tree_menu=mapper.s_tree_menu(params);
        result.put("s_tree_menu", s_tree_menu);
        
        
        SQLList<SQLMap> s_project_files=mapper.s_project_files(params,pagination);
        s_project_files.setPagedListInfo(pagination);
        result.put("s_project_files", s_project_files);
        
        
        
        return result;
    }
    /**
    发布文件流程修改
    */
    
    public Map publishFileStreamSubmit() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        Object useModuleId =
        mapper.useModuleId(params);
        result.put("useModuleId", useModuleId);
        
        
        n_file_work();
        
        
        int file_id = mapper.file_id(params);
        result.put("file_id", file_id);
        
        
        mapper.publishFileStreamSubmit(params);
        
        
        u_pre_begin_time();
        
        return result;
    }
    /**
    增加检测流程任务
    */
    
    public Map n_file_work() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        int plan_work_id = mapper.plan_work_id(params);
        result.put("plan_work_id", plan_work_id);
        
        
        int phase_work_id = mapper.phase_work_id(params);
        result.put("phase_work_id", phase_work_id);
        
        
        int item_work_id = mapper.item_work_id(params);
        result.put("item_work_id", item_work_id);
        
        
        int skipid = mapper.skipid(params);
        result.put("skipid", skipid);
        
        
        Object CMIDitem_work_id =
        mapper.CMIDitem_work_id(params);
        result.put("CMIDitem_work_id", CMIDitem_work_id);
        
        
        mapper.n_file_work(params);
        
        return result;
    }
    /**
    更新预算时间_wdy
    */
    
    public Map u_pre_begin_time() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> t_user=mapper.t_user(params);
        SQLMap t_user_emt=t_user.getExistfirst();
        result.put("t_user", t_user_emt);
        
        
        SQLList<SQLMap> s_steps=mapper.s_steps(params);
        result.put("s_steps", s_steps);
        
        
        SQLList<SQLMap> skips=mapper.skips(params);
        result.put("skips", skips);
        
        
        Object start_time =
        mapper.start_time(params);
        result.put("start_time", start_time);
        
        
        for (SQLMap emt:FrameHelper.createStepWorkTime(s_steps,skips,"item_work_id","dura_inttime")){
            params=new SQLParam(request,emt.getMap());
            params.put("_start_time",getAfterWorkHour(
            start_time
            ,emt.getInt("start_inttime")*1.0/3600
            ,t_user.getExistfirst().getString("station_type")
            ,t_user.getExistfirst().getString("org_id")
            ));
            params.put("_end_time",getAfterWorkHour(
            start_time
            ,emt.getInt("end_inttime")*1.0/3600
            ,t_user.getExistfirst().getString("station_type")
            ,t_user.getExistfirst().getString("org_id")
            ));
            mapper.u_pre_begin_time(params);
        }
        
        return result;
    }
    /**
    */
    
    public Map move_files() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        mapper.move_files(params);
        
        return result;
    }
    /**
    */
    
    public Map d_files0() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        mapper.d_files0(params);
        
        return result;
    }
    /**
    */
    
    public Map d_batch_files() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        for (SQLMap emt:hqlBean.getTableElements("")){
            params=new SQLParam(request,emt.getMap());
            mapper.d_batch_files(params);
        }
        
        return result;
    }
    /**
    */
    
    public Map unzip() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        //SQLList
        SQLList<SQLMap> unzipList=new SQLList();
        
        
        
        
        for (SQLMap emt:unzipList){
            params=new SQLParam(request,emt.getMap());
            mapper.b_files(params);
        }
        
        
        for (SQLMap emt:unzipList){
            params=new SQLParam(request,emt.getMap());
            mapper.b_files_version(params);
        }
        
        
        mapper.unzip(params);
        
        return result;
    }
    /**
    */
    
    public Map down() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        
        return result;
    }
    /**
    */
    
    public Map d_files_version() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        mapper.d_files_version(params);
        
        return result;
    }
    /**
    上传文件修改
    */
    
    public Map uploadFilesStrSubmit() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.def("fileid",null);
        mapper.uploadFilesStrSubmit(params);
        
        return result;
    }
    /**
    搜索文件修改
    */
    
    public Map pubFileSearchSubmit() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        return result;
    }
}